package tree.tree2.symmetry.Path;

import sun.reflect.generics.tree.Tree;
import tree.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName treePaths
 * @Description TODO
 * @Author lenovo
 * @Date 2023-05-04 10:08
 * @Version 1.0
 * @Comment Magic. Do not touch.
 * If this comment is removed. the program will blow up
 */
public class treePaths {


    public List<String> binaryTreePaths(TreeNode root) {
        List<String> path = new ArrayList<>();

        depth(root, "", path);
        return path;
    }

    private void depth(TreeNode root, String pre, List<String> path) {

        if (root.left == null && root.right == null) {
            path.add(pre + root.val);
            return;
        }
        depth(root.left, pre + root.val + "->", path);
        depth(root.right, pre + root.val + "->", path);
    }

    public static void main(String[] args) {
        TreeNode root = new TreeNode(1);
        root.left = new TreeNode(2);
        root.right = new TreeNode(3);

        treePaths treePaths = new treePaths();
        System.out.println(treePaths.binaryTreePaths(root));
    }
}